﻿using SuperSocket.SocketBase.Command;
using SuperSocketServer.SSBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperSocketServer.Command
{
    public class CMD_0004_DownText : CommandBase<MySession, MyRequestInfo>
    {
        private int Action = 4;

        public override string Name
        {
            get { return Action.ToString(); }
        }
        public override void ExecuteCommand(MySession session, MyRequestInfo requestInfo)
        {
            LogHelper.WriteLog(session.NickName + " 已确认客户端收到文本" + requestInfo.Body);
        }


        public void push(MySession mySession, string str)
        {
            //向客户端推送消息
            var response = BitConverter.GetBytes(Action).Reverse().ToList();
            var arr = Encoding.UTF8.GetBytes(str);
            response.AddRange(BitConverter.GetBytes(arr.Length).Reverse().ToArray());
            response.AddRange(Encoding.UTF8.GetBytes(str));
            mySession.Send(response.ToArray(),0,response.Count);
        }

    }
}
